package com.uniflow.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.time.LocalDateTime;

/**
 * 用户角色关联实体类
 * 
 * @author luban
 * @since 1.0.0
 */
@ApiModel(description = "用户角色关联")
public class UserRole {
    
    @ApiModelProperty("用户ID")
    private String userId;
    
    @ApiModelProperty("角色ID")
    private String roleId;
    
    @ApiModelProperty("分配时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime assignedAt;
    
    @ApiModelProperty("分配人ID")
    private String assignedBy;
    
    @ApiModelProperty("分配人姓名")
    private String assignedByName;
    
    // 关联查询字段
    @ApiModelProperty("用户信息")
    private User user;
    
    @ApiModelProperty("角色信息")
    private Role role;
    
    @ApiModelProperty("分配人信息")
    private User assigner;
    
    // 构造函数
    public UserRole() {}
    
    public UserRole(String userId, String roleId) {
        this.userId = userId;
        this.roleId = roleId;
        this.assignedAt = LocalDateTime.now();
    }
    
    public UserRole(String userId, String roleId, String assignedBy, String assignedByName) {
        this.userId = userId;
        this.roleId = roleId;
        this.assignedBy = assignedBy;
        this.assignedByName = assignedByName;
        this.assignedAt = LocalDateTime.now();
    }
    
    // Getter和Setter方法
    public String getUserId() {
        return userId;
    }
    
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    public String getRoleId() {
        return roleId;
    }
    
    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }
    
    public LocalDateTime getAssignedAt() {
        return assignedAt;
    }
    
    public void setAssignedAt(LocalDateTime assignedAt) {
        this.assignedAt = assignedAt;
    }
    
    public String getAssignedBy() {
        return assignedBy;
    }
    
    public void setAssignedBy(String assignedBy) {
        this.assignedBy = assignedBy;
    }
    
    public String getAssignedByName() {
        return assignedByName;
    }
    
    public void setAssignedByName(String assignedByName) {
        this.assignedByName = assignedByName;
    }
    
    public User getUser() {
        return user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    public Role getRole() {
        return role;
    }
    
    public void setRole(Role role) {
        this.role = role;
    }
    
    public User getAssigner() {
        return assigner;
    }
    
    public void setAssigner(User assigner) {
        this.assigner = assigner;
    }
    
    @Override
    public String toString() {
        return "UserRole{" +
                "userId='" + userId + '\'' +
                ", roleId='" + roleId + '\'' +
                ", assignedAt=" + assignedAt +
                ", assignedBy='" + assignedBy + '\'' +
                '}';
    }
}